<div class="main-content">
	<div class="breadcrumbs" id="breadcrumbs">
		<ul class="breadcrumb">
			<li>
				<i class="icon-home home-icon"></i>
				<a href="<?php echo PIUrl::createUrl('/admin');?>">Trang chủ</a>

				<span class="divider">
					<i class="icon-angle-right arrow-icon"></i>
				</span>
			</li>
			<li class="active"><?php echo translate('Theme');?></li>
		</ul>
	</div>

	<div class="page-content">
		<div class="page-header position-relative">
			<h1>
				<?php echo translate('Cập nhập theme');?>
			</h1>
		</div><!--/.page-header-->
		<div class="row-fluid">
			<div class="span12">
				<!--PAGE CONTENT BEGINS-->
				<?php $form = $this->beginWidget('CActiveForm', array(
					'id'=>'themes-form',
					//'enableAjaxValidation'=>true,
					'enableClientValidation'=>true,
					'focus'=>array($model,'title'),
					'htmlOptions'=>array('class'=>'form-horizontal', 'enctype'=>'multipart/form-data'),
				)); ?>
					
					<div class="control-group">
						<?php echo $form->labelEx($model,'id_category_theme',array('class'=>'control-label')); ?>
						<div class="controls">
							<?php echo $form->dropDownList($model,'id_category_theme',$dataCategories, array('class'=>'span12 id_category_theme')); ?>
							<?php echo $form->error($model,'id_category_theme'); ?>
						</div>
					</div>
		
					<div class="control-group">
						<?php echo $form->labelEx($model,'name',array('class'=>'control-label')); ?>
						<div class="controls">
							<?php echo $form->textField($model,'name',array('placeholder'=>'Tên webiste', 'class'=>'span12')); ?>
							<?php echo $form->error($model,'name'); ?>
						</div>
					</div>
					
					<div class="control-group">
						<?php echo $form->labelEx($model,'description',array('class'=>'control-label')); ?>
						<div class="controls">
							<?php echo $form->textArea($model,'description',array('placeholder'=>'Mô tả', 'class'=>'span12')); ?>
							<?php echo $form->error($model,'description'); ?>
						</div>
					</div>
					
					<div class="control-group">
						<?php echo $form->labelEx($model,'content',array('class'=>'control-label')); ?>
						<div class="controls">
							<?php echo $form->textArea($model,'content',array('placeholder'=>'Nội dung', 'class'=>'ckeditor')); ?>
							<?php echo $form->error($model,'content'); ?>
						</div>
					</div>
					
					<div class="control-group">
						<?php echo $form->labelEx($model,'price',array('class'=>'control-label')); ?>
						<div class="controls">
							<?php echo $form->textField($model,'price',array('placeholder'=>'Giá mua phần mềm', 'class'=>'span12')); ?>
							<?php echo $form->error($model,'price'); ?>
						</div>
					</div>
					
					<div class="control-group">
						<?php echo $form->labelEx($model,'alias_folder',array('class'=>'control-label')); ?>
						<div class="controls">
							<?php echo $form->textField($model,'alias_folder',array('placeholder'=>'Tên thư mục', 'class'=>'span12')); ?>
							<?php echo $form->error($model,'alias_folder'); ?>
						</div>
					</div>
					
					<div class="control-group">
						<div class="controls">
							<img src="
								<?php echo getImage($model->image, 80, 80); ?>
							"/>
						</div>
					</div>
						
					<div class="control-group">
						<?php echo $form->labelEx($model,'image',array('class'=>'control-label')); ?>
						<div class="controls">
							<?php echo $form->fileField($model,'image',array('id'=>'id-input-file-1', 'class'=>'span12')); ?>
							<?php echo $form->error($model,'image'); ?>
						</div>
					</div>
					
					<div class="control-group">
						<div class="controls">
							<img src="
								<?php echo getImage($model->image_detail, 80, 80); ?>
							"/>
						</div>
					</div>
					
					<div class="control-group">
						<?php echo $form->labelEx($model,'image_detail',array('class'=>'control-label')); ?>
						<div class="controls">
							<?php echo $form->fileField($model,'image_detail',array('class'=>'id-input-file-1-1 span12')); ?>
							<?php echo $form->error($model,'image_detail'); ?>
						</div>
					</div>
					
					<div class="control-group">
						<?php echo $form->labelEx($model,'fileSql',array('class'=>'control-label')); ?>
						<div class="controls">
							<?php echo $form->fileField($model,'fileSql',array('id'=>'', 'class'=>'span12 id-input-file-sql')); ?>
							<?php echo $form->error($model,'fileSql'); ?>
						</div>
					</div>
					
					<div class="control-group">
						<?php echo $form->labelEx($model,'theme',array('class'=>'control-label')); ?>
						<div class="controls">
							<?php echo $form->fileField($model,'theme',array('id'=>'', 'class'=>'span12 id-input-file-zip')); ?>
							<?php echo $form->error($model,'theme'); ?>
						</div>
					</div>
					
					<div class="form-actions">
						<button id="submitForm" class="btn btn-primary" type="submit">
							<i class="icon-ok bigger-110"></i>
							<?php echo translate('Cập nhập');?>
						</button>

						&nbsp; &nbsp; &nbsp;
						<button type="button" onclick="location.href='<?php echo PIUrl::createUrl('/admin');?>'" class="btn" >
							<i class="icon-undo bigger-110"></i>
							<?php echo translate('hủy');?>
						</button>
					</div>
				<?php $this->endWidget(); ?>
			</div><!--/.span-->
		</div><!--/.row-fluid-->
	</div><!--/.page-content-->
	</div><!--/.main-content-->
<script>
	$(document).ready(function(){
	
		$("#themes-form").submit(function(){
			if($(".id_category_theme").val() == 0){
				alert("Vui lòng chọn lĩnh vực của theme");
				return false
			}else	return true;
		});
		
		$('.id-input-file-sql').ace_file_input({
			no_file:'No File ...',
			btn_choose:'Chọn file',
			btn_change:'Thay đổi',
			droppable:false,
			onchange:null,
			before_change:before_change_sql,
			thumbnail:false, //| true | large
			//whitelist:'gif|png|jpg|jpeg|zip',
			blacklist:'exe|php'
			//onchange:''
		});
		
		$('.id-input-file-zip').ace_file_input({
			no_file:'No File ...',
			btn_choose:'Chọn file',
			btn_change:'Thay đổi',
			droppable:false,
			onchange:null,
			before_change:before_change_zip,
			thumbnail:false, //| true | large
			//whitelist:'gif|png|jpg|jpeg|zip',
			blacklist:'exe|php'
			//onchange:''
		});
		
		$('#id-input-file-1, .id-input-file-1-1').ace_file_input({
			no_file:'No File ...',
			btn_choose:'Chọn file',
			btn_change:'Thay đổi',
			droppable:false,
			onchange:null,
			before_change:before_change_image,
			thumbnail:false, //| true | large
			//whitelist:'gif|png|jpg|jpeg'
			blacklist:'exe|php'
			//onchange:''
		});
	
	})
	
	// validate khi upload file .zip
	before_change_zip = function(files, dropped) {
		var allowed_files = [];
		for(var i = 0 ; i < files.length; i++) {
			var file = files[i];
			if(typeof file === "string") {
				//IE8 and browsers that don't support File Object
				if(! (/\.(zip)$/i).test(file) ) return false;
			}
			else {
			
				var type =   file.name.split('.').pop().toLowerCase();

				if( ( type.length > 0 && (/\.zip$/).test(file.name))
						//for android's default browser which gives an empty string for file.type
					)	allowed_files.push(file);
				else	continue;//not an image so don't keep this file
			}
		}
		if(allowed_files.length == 0) {message('Chỉ cho phép tải file .zip .','error'); return false};
		return allowed_files;
	}
	
	// validate khi upload file .sql
	before_change_sql = function(files, dropped) {
		var allowed_files = [];
		for(var i = 0 ; i < files.length; i++) {
			var file = files[i];
			if(typeof file === "string") {
				//IE8 and browsers that don't support File Object
				if(! (/\.(zip)$/i).test(file) ) return false;
			}
			else {
			
				var type =   file.name.split('.').pop().toLowerCase();

				if( ( type.length > 0 && (/\.sql$/).test(file.name))
						//for android's default browser which gives an empty string for file.type
					)	allowed_files.push(file);
				else	continue;//not an image so don't keep this file
			}
		}
		if(allowed_files.length == 0) {message('Chỉ cho phép tải file .sql .','error'); return false};
		return allowed_files;
	}
	
	// validate khi upload file hinh anh
	before_change_image = function(files, dropped) {
		var allowed_files = [];
		for(var i = 0 ; i < files.length; i++) {
			var file = files[i];
			console.log(file);
			if(typeof file === "string") {
				//IE8 and browsers that don't support File Object
				if(! (/\.(jpe?g|png|gif|bmp)$/i).test(file) ) return false;
			}
			else {
				var type = $.trim(file.type);
				if( ( type.length > 0 && ! (/^image\/(jpe?g|png|gif|bmp)$/i).test(type) )
						|| ( type.length == 0 && ! (/\.(jpe?g|png|gif|bmp)$/i).test(file.name) )//for android's default browser which gives an empty string for file.type
					) continue;//not an image so don't keep this file
			}
			
			allowed_files.push(file);
		}
		if(allowed_files.length == 0) {message('Chỉ cho phép tải lên hình ảnh.','error'); return false};
		if(allowed_files[0].size > 2048000) {message('Kích thước ảnh quá lớn(phải nhỏ hơn 2048KB).','error'); return false};
		return allowed_files;
	}
</script>
<style>
.checkBox{
	display:inline !important;
	opacity:1 !important;
	position:relative !important;
}
#Prices_id label{display:inline !important;}
</style>